﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ClientWPF.localhost;

namespace ClientWPF
{
    public partial class UserPanel : Window
    {
        Service1 service = new Service1();
        AuthentificationCredentials authentification = new AuthentificationCredentials();

        public UserPanel()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            ProductsDataGrid.ItemsSource = service.GetAllProducts();
        }

        private void BuyProductButton_Click(object sender, RoutedEventArgs e)
        {
            string selection = ProductsDataGrid.Name;
            Product product = new Product();
            product.Name = selection;
            var form = new BuyProductForm();
            form.Show();
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            var form = new MainWindow(); //LogInForm
            Close();
            form.Show();
        }

        private void CategoryComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string selection = (string)((ComboBoxItem)CategoryComboBox.SelectedItem).Content;
            Product product = new Product();
            product.Category = selection;
            ProductsDataGrid.ItemsSource = service.GetProductsByCategory(product);
        }

        private void ProductsDataGrid_SendItem(object sender, SelectionChangedEventArgs e)
        {
            string selection = ProductsDataGrid.Name;
            Product product = new Product();
            product.Name = selection;
        }
    }
}
